{{ define "user/user_center_info.html" }}

{{ template "base/base_header.html" . }}
<head>
	<title>天天生鲜-用户中心</title>
	{{template "base/base_import.html" . }}
</head>
<body>
	{{ template "base/base_top.html" . }}

	{{ template "base/base_search.html" .}}

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a href="/ttsx/user/user_center_info" class="active">· 个人信息</a></li>
				<li><a href="/ttsx/user/user_center_order/1">· 全部订单</a></li>
				<li><a href="/ttsx/user/user_center_site">· 收货地址</a></li>
			</ul>
		</div>
		<div class="right_content clearfix">
				<div class="info_con clearfix">
				<h3 class="common_title2">基本信息</h3>
						<ul class="user_info_list">
							<li><span>用户名：</span>{{ .Name }}</li>
							<li><span>联系方式：</span>{{ .Phone }}</li>
							<li><span>联系地址：</span>{{ .Address }}</li>			
						</ul>
				</div>
				
				<h3 class="common_title2">最近浏览</h3>
				<div class="has_view_list">
					<ul class="goods_type_list clearfix">
						{{ range $i, $v := .GoodList }}
							<li>
								<a href="/ttsx/goods/detail?id={{ $v.ID }}"><img src="{{ $v.Image }}"></a>
								<h4><a href="/ttsx/goods/detail?id={{ $v.ID }}">{{ $v.Name }}</a></h4>
								<div class="operate">
									<span class="prize">￥{{ $v.Price }}</span>
									<span class="unit">{{ $v.Price }}/{{ $v.Unite }}</span>
									<a href="javascript:;" sku_id="{{ $v.ID }}" class="add_goods" id="add_cart" title="加入购物车"></a>
								</div>
							</li>
						{{ else }}
							无历史浏览记录
						{{ end }}
					</ul>
				</div>
		</div>
	</div>
	{{ .errMsg }}
	{{ template "base/base_bottom.html" . }}

	<script type="text/javascript"> 
		$('#add_cart').click(function(){
			// 获取 sku_id 和 count
			sku_id = $(this).attr('sku_id')
			count = 1

			$.ajax({
				url: "/ttsx/cart/add",
				type: "post",
				dataType: "json",
				data: {"sku_id": sku_id, "count": count}
			}).done(function(data){
				if (data.Code == 3) {
					alert("添加购物车成功")
					// location.reload()
				}else {
					alert(data.errMsg)
				}
			}).fail(function(){
				alert("请登录后添加")
			})

		})
	</script>
	
</body>
</html>

{{ end }}